define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

		function get_data_panicbuying_list(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"act": [' +
					'{"act_id": "001","act_name": "限时抢购","store_id": "001","store_name": "上海五金店","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00",' +
					'"introduction": "双十一期间限时抢购","store_id": "001","store_name": "无锡五金公司","region": [' +
					'{"region_name": "江苏-苏州-汾湖"},{"region_name": "上海-上海-闸北"}],"image": {"id": "001","image": "./img/upload/pro-img02.jpg"}},' +
					'{"act_id": "002","act_name": "促销","store_id": "002","store_name": "北京五金店","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00",' +
					'"introduction": "双十一期间限时抢购","store_id": "002","store_name": "上海五金公司","region": [' +
					'{"region_name": "江苏-苏州-汾湖"},{"region_name": "上海-上海-闸北"}],"image": {"id": "002","image": "./img/upload/pro-img02.jpg"}}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}
		
		//返回信息
		return {
			panicbuying_list: function(nPage,act_type,callback,calldone) {
				Http.post({
					method: 'marketing.panicbuy.viewlist',
					pagelimit: 20,
					nPage: nPage,
					act_type:act_type
				}, function(result) {
					if(callback)
						callback(get_data_panicbuying_list(result).result,result.process_time);
				}, function(e) {

				}, function() {
					if(calldone)
						calldone();
				})
			},
			//轮播图
			getBannerList: function(callback) {
				Http.post({
					method: 'marketing.banner.getlist',
					act_type:3
				}, function(result) {
					if(callback) {
						callback(result);
					}
				}, function(e) {
					//请求异常
				}, function() {
					
				});
			}
			
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Panicbuying", factory);
});